<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='评论管理',active='comments'">
<header th:replace="back/header::headerFragment(${title},${active})"></header>
<head>
    <meta th:name="_csrf" th:content="${_csrf.token}"/>
    <!-- 默认的header name是X-CSRF-TOKEN -->
    <meta th:name="_csrf_header" th:content="${_csrf.headerName}"/>
</head>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="back/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">评论管理</h4>
                    </div>
                    <div class="col-md-12">
<!--                        程序猿正熬夜实现以下功能···-->



                        <div th:if="${comments==null or comments.size()==0}" class="row">
                            <div class="col-md-4 text-center">
                                <div class="alert alert-warning">
                                    目前还没有评论哦！
                                </div>
                            </div>
                        </div>

                        <div class="table-responsive">
                            <table th:if="${comments!=null and comments.size()>0}" class="table table-striped table-bordered">
                                <thead>
                                <tr>
                                    <th>评论内容</th>
                                    <th>评论人</th>
                                    <th>评论时间</th>
                                    <th>评论人ip</th>
                                    <th>评论状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="comment:${comments}">
                                    <td th:text="${comment.getC_content()}"></td>
                                    <td th:text="${comment.getAuthor()}"></td>
                                    <td th:text="${commons.dateFormat(comment.getCreated())}"></td>
                                    <td th:text="${comment.getIp()}"></td>
                                    <td>
                                        <div th:if="${comment.getStatus()} eq 'approved'">
<!--                                            <span v-if="item.authorId == ${login_user.uid}" class="label label-success">后台回复</span>-->
                                            <span th:if="${comment.getStatus()} eq 'approved'" class="label label-success">审核通过</span>
                                        </div>
                                        <div th:if="${comment.getStatus()} eq 'no_audit'">
<!--                                            <span v-if="item.authorId == ${login_user.uid}" class="label label-default">后台回复</span>-->
                                            <span th:if="${comment.getStatus()} eq 'no_audit'" class="label label-default">未审核</span>
                                        </div>
                                    </td>
                                    <td>
<!--                                        <button v-if="item.authorId != ${login_user.uid}" class="btn btn-primary btn-sm waves-effect waves-light m-b-5" @click="reply(item.coid)"><i class="fa fa-reply"></i> 回复</button>-->
                                        <a th:href="@{pear_admin}" th:if="${comment.getStatus()} eq 'no_audit'" class="btn btn-primary btn-sm waves-effect waves-light m-b-5">
                                            <i class="fa fa-check-circle"></i> 确认通过</span>
                                        </a>
                                        <button th:if="${comment.getStatus()} eq 'approved'" class="btn btn-success btn-sm waves-effect waves-light m-b-5" @click="audit(item.coid, 'approved')">
                                            <i class="fa fa-check-circle"></i> 已通过</span>
                                        </button>
                                        <a href="#" class="btn btn-danger btn-sm waves-effect waves-light m-b-5" th:onclick="isdel(this,[[${comment.getId()}]])"><i class="fa fa-trash-o"></i> 删除</a>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="am-pagination">
                            <nav aria-label="Page navigation">

                                <!--                分成三个ul class="pagination" ，一个是上一页 ，一个是th：each遍历 ，一个是下一页-->
                                <ul class="pagination">

                                    <li th:if="${pageInfo.pageNum!=1}">
                                        <a th:href="@{'/admin/toCommentList?pageNum='+${pageInfo.pageNum-1}}" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                    <li th:if="${pageInfo.pageNum==1}" class="disabled">
                                        <a href="#" aria-label="Previous">
                                            <span aria-hidden="true">&laquo;</span>
                                        </a>
                                    </li>
                                </ul>

                                <ul class="pagination" th:each="index:${#numbers.sequence(1, pageInfo.getPages())}">
                                    <li th:if="${pageInfo.pageNum==index}" class="active"><a th:href="@{'/admin/toCommentList?pageNum='+${index}}" th:text="${index}"></a></li>
                                    <li th:if="${pageInfo.pageNum!=index}"><a th:href="@{'/admin/toCommentList?pageNum='+${index}}" th:text="${index}"></a></li>

                                </ul>

                                <ul class="pagination">
                                    <li th:if="${pageInfo.pageNum!=pageInfo.pages}">
                                        <a th:href="@{'/admin/toCommentList?pageNum='+${pageInfo.pageNum+1}}" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                    <li th:if="${pageInfo.pageNum==pageInfo.pages}" class="disabled">
                                        <a href="#" aria-label="Next">
                                            <span aria-hidden="true">&raquo;</span>
                                        </a>
                                    </li>
                                </ul>
                            </nav>
                        </div>




                    </div>
                </div>
                <div th:replace="back/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="back/footer :: footer"></div>

</body>

<script>
    function isdel(comment,commentid) {
        var isdel = confirm("你是否要删除这条评论");
        if(isdel==true){
            comment.href="/admin/toCommentList?delId="+commentid;
            alert("删除成功")
        }

    }
</script>

</html>